package com.zmsoft.boxy.sfg.api;

import javax.annotation.Resource;

import org.cnsoft.framework.beans.common.RESTResultBean;
import org.cnsoft.framework.beans.user.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cnsoft.material.IMaterialConstants;
import com.zmsoft.boxy.sfg.MySFGControllerSupport;
import com.zmsoft.boxy.sfg.player.BoxySFGPlayer;
import com.zmsoft.boxy.sfg.service.SFGGameActionService;
import com.zmsoft.boxy.sfg.service.SFGPlayerInfoService;

/**
 * 玩家角色资料接口
 * 
 * @version 1.0.0 2014/11/19
 * @since 1.0.0 2014/11/19
 */
@Controller
//@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@RequestMapping(value = "/game/1.0/sfg/player")
public class SFGPlayerInfoApiController extends MySFGControllerSupport implements IMaterialConstants {

	@Resource
	private SFGPlayerInfoService mySFGPlayerInfoService;
	
	@Resource
	private SFGGameActionService mySFGGameActionService;
	
	/**
	 * 玩家农场信息
	 */
	@RequestMapping(value = "/farm.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerFarm(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerFarm(player.init());
	}

	/**
	 * 玩家土地信息
	 */
	@RequestMapping(value = "/land.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerLand(BoxySFGPlayer player) throws Exception {
		player.init();
		return mySFGPlayerInfoService.loadPlayerLands(player.init());
	}

	/**
	 * 玩家仓库信息-查看
	 */
	@RequestMapping(value = "/warehouse.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerWarehouse(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerWarehouse(player.init());
	}
	
	/**
	 * 玩家仓库信息-出售
	 */
	@RequestMapping(value = "/warehouse-sell.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerWarehouseSell(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerWarehouse(player.init());
	}
	/**
	 * 玩家仓库信息-扩建
	 */
	@RequestMapping(value = "/warehouse-build.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerWarehouseBuild(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerWarehouse(player.init());
	}

	/**
	 * 玩家口袋信息
	 */
	@RequestMapping(value = "/pocket.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerPocket(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerPocket(player.init());
	}
	/**
	 * 玩家口袋信息-使用
	 */
	@RequestMapping(value = "/pocket-use.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerPocketUse(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerWarehouse(player.init());
	}
	/**
	 * 玩家口袋信息-销毁
	 */
	@RequestMapping(value = "/pocket-drop.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerPocketDrop(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerWarehouse(player.init());
	}
	
	/**
	 * 商店信息
	 */
	@RequestMapping(value = "/store.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doStore(BoxySFGPlayer player) throws Exception {
		return mySFGGameActionService.loadShop(player.init());
	}
	/**
	 * 商店信息-购买
	 */
	@RequestMapping(value = "/store-buy.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doStoreBuy(BoxySFGPlayer player) throws Exception {
		return mySFGGameActionService.doShopBuy(player.init());
	}
	
	/**
	 * 玩家好友信息
	 */
	@RequestMapping(value = "/friends.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doPlayerFriend(BoxySFGPlayer player) throws Exception {
		return mySFGPlayerInfoService.loadPlayerFriend(player.init());
	}
}
